#pragma once
#ifndef Game_GameEngine_SceneManager_h
#define Game_GameEngine_SceneManager_h

#include "Scene.h"

namespace Game {
namespace Common {

template<typename T>
class Collection;

class EntityLogicManager;
class SceneManagerIterator;

class SceneManager : public DrawableEntity, public ICollection<Scene*> {
    RTTI_DECL;
public:
    friend SceneManagerIterator;
    SceneManager();
    virtual ~SceneManager();
    EntityLogicManager* GetEntityLogicManager() const;
    void SetEntityLogicManager(EntityLogicManager* val);
    virtual int GetCount();
    virtual void Add(Scene* item);
    virtual void Clear();
    virtual Scene* GetItem(int index);
    virtual int IndexOf(Scene* item);
    virtual bool Remove(Scene* item);
    virtual void RemoveAt(int index);
private:
    EntityLogicManager* entityLogicManager;
    Collection<Scene*>* scenes;
};

class SceneManagerIterator : public ICollectionIterator<Scene*> {
public:
    SceneManagerIterator(SceneManager* sceneManager) : sceneManager(sceneManager) {
        this->iterator = CollectionIterator<Scene*>(this->sceneManager->scenes);
    }

    ~SceneManagerIterator() {
    }

    virtual void operator++() {
        this->iterator++;
    }

    virtual void operator ++(int) {
        this->iterator++;
    }

    virtual bool operator()() {
        return this->iterator();
    }

    virtual Scene* operator *() {
        return *this->iterator;
    }
private:
    SceneManager* sceneManager;
    CollectionIterator<Scene*> iterator;
};

}
}

#endif
